<%@ page language="java" pageEncoding="UTF-8" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
Boolean isAdd =request.getParameter("add")==null?Boolean.TRUE: Boolean.valueOf(request.getParameter("add"));
Boolean isDelete = request.getParameter("delete")==null?Boolean.TRUE: Boolean.valueOf(request.getParameter("delete"));
Boolean isRefresh = request.getParameter("refresh")==null?Boolean.TRUE:Boolean.valueOf(request.getParameter("refresh"));
Boolean isPage =request.getParameter("page")==null?Boolean.TRUE: Boolean.valueOf(request.getParameter("page"));
Boolean isSearch = request.getParameter("search")==null?Boolean.TRUE:Boolean.valueOf(request.getParameter("search"));
Boolean isSearchType = request.getParameter("searchType")==null?Boolean.TRUE:Boolean.valueOf(request.getParameter("searchType"));
%>

<% if(isAdd){ %>
	<a id="QBar_Add" href="javascript:;" class="iconButton">
		<span class="addIcon">&nbsp;</span><span class="text">添加</span>
	</a>
<% } %>

<% if(isDelete || isRefresh || isPage){ %>
	<div class="buttonWrap">
	
	<% if(isDelete){ %>
		<a id="QBar_Del" href="javascript:;" class="iconButton disabled">
			<span class="deleteIcon">&nbsp;</span>删除
		</a>
	<% } %>
	
	<% if(isRefresh){ %>
		<a id="QBar_Refresh" href="javascript:;" class="iconButton">
			<span class="refreshIcon">&nbsp;</span>刷新
		</a>
	<% } %>	
		
	<% if(isPage){ %>
		<div class="menuWrap">
			<a href="javascript:;" class="popupBtn button">
				每页显示<span class="arrow">&nbsp;</span>
			</a>
			<div class="popupMenu" id="QBar_Page">
				<ul>
					<li>
						<a href="javascript:;" value="10" class="current">10</a>
					</li>
					<li>
						<a href="javascript:;" value="20">20</a>
					</li>
					<li>
						<a href="javascript:;" value="50">50</a>
					</li>
					<li>
						<a href="javascript:;" value="100">100</a>
					</li>
				</ul>
			</div>
		</div>
	<% } %>	
	</div>
<% } %>

<% if(isSearch && isSearchType){ %>
	<div class="menuWrap">
	
	<% if(isSearch){ %>
		<div class="search">
			<span class="popupBtn arrow">&nbsp;</span>
			<input type="text" id="QBar_Text" maxlength="200" />
			<button id="QBar_Query" type="button">&nbsp;</button>
		</div>
		<div class="popupMenu" id="QBar_SearchKey">
			<ul>
			<%
				String[] typeOption = request.getParameterValues("searchKey");
				for(String str : typeOption){
					String[] tmp = str.split(",");
			%>
					<li>
						<a href="javascript:;" value="<%=tmp[0] %>" pattern="<%=tmp[2] %>"
					<% if(tmp.length==4 && "true".equals(tmp[3])){ %> 
						class="current" 
					<% } %>
						><%=tmp[1] %></a>
					</li>
			<% } %>
			</ul>
		</div>
		<script type="text/javascript">
			var pop_mouseover_fn = function(event){
				var offset = $(this).offset();
				var $menuWrap = $(this).closest("div.menuWrap");
				var $popupMenu = $menuWrap.children("div.popupMenu");
				$popupMenu.css({left: offset.left, top: offset.top + $(this).height() + 2}).show();
				$menuWrap.mouseleave(function() {
					$popupMenu.hide();
				});
			};
	
			var pop_item_select_fn = function(){
				$(this).closest("ul").find(".current").removeClass("current");
				$(this).addClass("current");
			}
				
			$(".popupBtn").mouseover(pop_mouseover_fn);
			$(".popupMenu li a").click(pop_item_select_fn);
		</script>
	<% } %>
	</div>
<% } %>
